package com.wbs.shop.nuby.api;


import com.wbs.shop.nuby.commom.Key;
import com.wbs.shop.nuby.utils.DOMStorageUtils;
import com.wbs.shop.nuby.utils.Logger;
import com.wbs.shop.nuby.utils.StringUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by zhy on 16/3/1.
 */
public class HeaderInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();
        String session = DOMStorageUtils.getSession(Key.TOKEN);
//        String session = "aa9716e098b7ce09ded24c357fab19d0";
        if (StringUtils.isNotEmpty(session)) {
            builder.header("TOKEN", session);
        } else {
            Logger.e("token为空");
        }
        return chain.proceed(builder.build());
    }

}
